home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / PGM_TOOL / RLINE_OP / OVIEW.PAS < prev    next >
Pascal/Delphi Source File  |  1989-10-10  |  6KB  |  267 lines

  1. {$A+,B-,D+,E-,F-,I-,L+,N-,O-,R-,S-,V-}
  2. {$M 16384,0,655360}
  3.  
  4. USES
  5.   CRT, moveops, rline, Readers;
  6.  
  7. CONST
  8.   BufferSize = 4096;  { Size for disk buffer. }
  9.  
  10. TYPE
  11.   Vptr = ^Ofiles;
  12.   Ofiles = Object(Reader)
  13.     CONSTRUCTOR Init(FN : String;
  14.               px1,py1,px2,py2 : integer);
  15.     PROCEDURE ShowStatus; virtual;
  16.     PROCEDURE Parse(ParseSt : string); virtual;
  17.     PROCEDURE ReSize(px1,px2,px3,px4 : integer);
  18.   END;
  19.  
  20.   OdeclareP = ^Odeclare;
  21.   Odeclare = Object(Ofiles)
  22.     CONSTRUCTOR Init(FN : String;
  23.               px1,py1,px2,py2 : integer);
  24.     PROCEDURE Parse(ParseSt : string); virtual;
  25.   END;
  26.  
  27.   OmethodsP = ^Omethods;
  28.   Omethods = Object(Ofiles)
  29.     CONSTRUCTOR Init(FN : String;
  30.               px1,py1,px2,py2 : integer);
  31.     PROCEDURE Parse(ParseSt : string); virtual;
  32.   END;
  33.  
  34. { OFILES ====================================================================}
  35.  
  36.   CONSTRUCTOR Ofiles.Init(FN : String;
  37.               px1,py1,px2,py2 : integer);
  38.   BEGIN
  39.     If not Reader.Init(FN,BufferSize,px1,py1,px2,py2)
  40.     then fail;
  41.     checkrferror;
  42.     tofl;
  43.     checkrferror;
  44.   END;
  45.  
  46.   PROCEDURE Ofiles.ShowStatus;
  47.   BEGIN
  48.     gotoxy(1,2);
  49.     write(FO.FileName);
  50.     clreol;
  51.     gotoxy(x1,y1-1);
  52.     write('░░░░░░░░░░ Line ',IxnoY1, ' of ', TotalItems, ' ░░░░░░░░░░');
  53.   END;
  54.  
  55.   PROCEDURE Ofiles.Parse(ParseSt : string); BEGIN END;
  56.  
  57.   PROCEDURE OFiles.ReSize(px1,px2,px3,px4 : integer);
  58.   BEGIN
  59.     Rectangle.Init(px1,px2,px3,px4);
  60.     wrscr;
  61.     showstatus;
  62.   END;
  63.  
  64. { Odeclare ====================================================================}
  65.  
  66.   CONSTRUCTOR Odeclare.Init(FN : String;
  67.               px1,py1,px2,py2 : integer);
  68.   BEGIN
  69.     OFiles.Init(FN,px1,py1,px2,py2);
  70.   END;
  71.  
  72.   PROCEDURE Odeclare.Parse(ParseSt : string);
  73.   var
  74.     firstix, oldix : longint;
  75.     found : boolean;
  76.     i : integer;
  77.   BEGIN
  78.     searchstring := 'OBJECT';
  79.     casesensitive := false;
  80.     found := false;
  81.     REPEAT
  82.       firstix := ixnoy1;
  83.       REPEAT
  84.     oldix := ixnoy1;
  85.     searchforward;
  86.     i := pos('=', dtaline(ixnoy1) );
  87.     found := (ixnoy1 > oldix)
  88.           and (i > 0)
  89.           and (pos(':', dtaline(ixnoy1)) <> i-1);
  90.       UNTIL (oldix = ixnoy1) or found;
  91.       if not(found) and (firstix > 1)
  92.       then ixnoy1 := 1;
  93.       showstatus;
  94.     UNTIL found or (firstix = 1);
  95.   END;
  96.  
  97.  
  98. { Omethods ====================================================================}
  99.  
  100.   CONSTRUCTOR Omethods.Init(FN : String;
  101.               px1,py1,px2,py2 : integer);
  102.   BEGIN
  103.     OFiles.Init(FN,px1,py1,px2,py2);
  104.   END;
  105.  
  106.   PROCEDURE Omethods.Parse(ParseSt : string);
  107.   var
  108.     s : string;
  109.     i : integer;
  110.     ss : string[10];
  111.     firstix,oldix : Longint;
  112.     found : boolean;
  113.   BEGIN
  114.     s := ParseSt;
  115.     ss := 'OBJECT';
  116.     if InSensitiveMatch(ss,s) THEN BEGIN  { OBJECT found. }
  117.       i := pos('=',s);                    { ' xxx = Object'}
  118.       if i > 0 then BEGIN
  119.     UpcaseString(S);                  { ' XXX '}
  120.     s := copy(s,1,i-1);               { ' XXX '}
  121.     while (length(s) > 0) and (s[length(s)] in [' ', ^I])
  122.     do dec(s[0]);                     { ' XXX' }
  123.     REPEAT
  124.       i := pos(' ',s);
  125.       if i = 0 then i := pos(^I,s);
  126.       if i > 0 then delete(s,1,i);
  127.     UNTIL i = 0;                      { 'XXX' }
  128.     if length(s) > 0 then BEGIN
  129.       s:= s + '.';
  130.       if SearchString <> S THEN BEGIN
  131.         SearchString := s;
  132.         casesensitive := false;
  133.         IxnoY1 := 1;
  134.       END;
  135.     END;
  136.       END;
  137.     END;
  138.  
  139.     REPEAT
  140.       firstix := ixnoy1;
  141.       REPEAT
  142.     oldix := Ixnoy1;
  143.     SearchForward;
  144.     if oldix <> ixnoy1 then BEGIN
  145.       s := DTAline(ixnoy1);
  146.       UpcaseString(s);
  147.       found := (pos('PROCEDURE',S) > 0) OR (pos('FUNCTION',s)>0)
  148.          OR (pos('CONSTRUCTOR',S)>0) OR (pos('DESTRUCTOR',s)>0);
  149.     END;
  150.       UNTIL found or (ixnoy1 = oldix);
  151.       if not found and (firstix > 1)
  152.       then ixnoy1 := 1;
  153.       showstatus;
  154.     UNTIL found or (firstix = 1);
  155.   END;
  156.  
  157. PROCEDURE ClrViewScr;
  158. BEGIN
  159.   window(1,3,80,25);
  160.   clrscr;
  161.   window(1,1,80,25);
  162. END;
  163.  
  164.  
  165. TYPE
  166.   VRay = array[Boolean] of VPtr;
  167.  
  168.   PROCEDURE Perspective(var vs : vray; Horizontal : boolean);
  169.   BEGIN
  170.     ClrViewScr;
  171.     CASE Horizontal of
  172.       false: BEGIN
  173.            vs[false]^.ReSize(1, 4, 38, 25);
  174.            vs[true]^.ReSize(42, 4, 80, 25);
  175.          END;
  176.       true : BEGIN
  177.            vs[false]^.ReSize(1, 4, 80, 11);
  178.            vs[true]^.ReSize(1, 13, 80, 25);
  179.          END;
  180.     END;
  181.   END;
  182.  
  183.   PROCEDURE Expand(var vs : VRay; cur : boolean);
  184.   BEGIN
  185.     ClrViewScr;
  186.     case cur of
  187.       false : BEGIN
  188.         vs[false]^.ReSize(1, 4, 80, 23);
  189.         vs[true]^.ReSize(1, 25, 80, 25);
  190.           END;
  191.       true : BEGIN
  192.         vs[false]^.ReSize(1, 4, 80, 4);
  193.         vs[true]^.ReSize(1, 6, 80, 25);
  194.           END;
  195.     END;
  196.   END;
  197.  
  198. { Main Program -------------------------------------------------------}
  199. VAR
  200.   Vs : VRay;
  201.   cur, View, Expanded : boolean;
  202.   c : char;
  203.   fn : string;
  204. BEGIN
  205.   clrscr;
  206.   if paramcount = 0 then BEGIN
  207.     writeln('OVIEW FileName');
  208.     writeln('  Scrolls through Objects in TP 5.5 source code.');
  209.     halt;
  210.   END;
  211.  
  212.   fn := paramstr(1);
  213.   if pos('.',fn) = 0       { insert default PAS extension. }
  214.   then fn := fn + '.PAS';
  215.  
  216.   vs[false] := New(OdeclareP, init(fn, 1, 4, 38, 25));
  217.   vs[true] := New(OmethodsP, init(fn, 42, 4, 80, 25));
  218.   IF (vs[false] = nil) or (vs[true] = nil) then begin
  219.     Writeln('Not enough ram available');
  220.     halt(1);
  221.   END;
  222.  
  223.   gotoxy(1,1);
  224.   Writeln(' [V]iew  [+/Enter] next object/method  [tab] next window  [E]xpand  [F1] help');
  225.  
  226.   vs[false]^.Parse('');
  227.   vs[true]^.Parse(vs[false]^.DTAline(vs[false]^.IxnoY1));
  228.  
  229.   cur := false;
  230.   view := false;
  231.   expanded := false;
  232.   REPEAT
  233.     c := vs[cur]^.scrollselect;
  234.     vs[cur]^.checkrferror;
  235.     CASE c of
  236.       ^M : vs[true]^.Parse(vs[false]^.DTAline(vs[false]^.IxnoY1));
  237.       ^I : BEGIN
  238.          cur := not cur;
  239.          if expanded then Expand(vs,cur);
  240.        END;
  241.       '+': BEGIN
  242.          vs[false]^.Parse('');
  243.          with vs[true]^ do begin
  244.            ixnoy1 := 1;
  245.            Parse(vs[false]^.DTAline(vs[false]^.IxnoY1));
  246.            if ixnoy1 = 1 then wrscr;
  247.          end;
  248.        END;
  249.       'v',
  250.       'V': BEGIN
  251.          View := Not View;
  252.          Expanded := false;
  253.          Perspective(vs,View);
  254.        END;
  255.       'e',
  256.       'E': BEGIN  { Expand. }
  257.          Expanded := Not Expanded;
  258.          IF Expanded
  259.          THEN Expand(vs,cur)
  260.          ELSE Perspective(vs,View);
  261.            END;
  262.     END;
  263.   UNTIL c = #27;
  264.  
  265.   clrscr;
  266.   for cur := false to true do Dispose(vs[cur],done);
  267. END.